package com.ctgu.蓝桥杯真题.B组2019;

import javafx.util.Pair;

import java.io.*;
import java.util.LinkedList;
import java.util.Queue;

/**
 * @author: Backdiy
 * @data: 2021/4/8 21:22
 * @desc:
 */
public class E迷宫 {

    static int n = 30, m = 50;
    static String[] s = new String[n];
    static int[][] dir = new int[][]{{1, 0}, {0, -1}, {0, 1}, {-1, 0}};
    static int[][] map = new int[n][m];
    static Pair<Integer, Integer> p0 = new Pair<Integer, Integer>(0, 0);
    static Queue<Pair<Pair<Integer, Integer>,String>> objects = new LinkedList<>();

    public static void main(String[] args) throws IOException {
        BufferedReader fileReader = new BufferedReader(new InputStreamReader(new FileInputStream("E:\\蓝桥杯真题B组java\\2019年\\maze.txt")));
        for (int i = 0; i < n; i++) {
            s[i] = fileReader.readLine();
        }
        objects.offer(new Pair<>(p0,""));
        map[0][0] = 1;
        while (!objects.isEmpty()) {
            Pair<Pair<Integer, Integer>, String> p = objects.poll();
            if (p.getKey().getKey() == 29 && p.getKey().getValue() == 49) {
                Input.out.println(p.getValue());
                Input.out.flush();
                break;
            }
            for (int i = 0; i < 4; i++) {
                int x = dir[i][0] + p.getKey().getKey();
                int y = dir[i][1] + p.getKey().getValue();
                String ans = p.getValue();
                if (x >= 0 && y >= 0 && x < n && y < m && map[x][y] == 0 && s[x].charAt(y)=='0') {
                    if (i == 0) {
                        ans += "D";
                    } else if (i == 1) {
                        ans += "L";
                    } else if (i == 2) {
                        ans += "R";
                    } else {
                        ans += "U";
                    }
                    objects.offer(new Pair<>(new Pair<>(x, y),ans));
                    map[x][y] = 1;
                }
            }
        }
    }

    static class Input {
        static StreamTokenizer streamTokenizer = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        static PrintWriter out = new PrintWriter((new OutputStreamWriter(System.out)));
        static BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));

        static int nextInt() throws IOException {
            streamTokenizer.nextToken();
            return (int) streamTokenizer.nval;
        }

        static double nextDouble() throws IOException {
            streamTokenizer.nextToken();
            return streamTokenizer.nval;
        }

        static long nextLong() throws IOException {
            streamTokenizer.nextToken();
            return (long) streamTokenizer.nval;
        }

        static String nextLine() throws IOException {
            return bufferedReader.readLine();
        }

        static char next() throws IOException {
            return (char) bufferedReader.read();
        }
    }
}
